Here is the seventh and final blog post:
🚀 Blog 7: Implementing Local CI/CD with GitHub Actions & Minikube (Windows Edition)
Welcome to the final part of our DevOps series! Now that you have a working Kubernetes cluster with autoscaling, ingress, and monitoring, it's time to automate deployments using CI/CD.
In this post, we’ll set up a local CI/CD pipeline that builds, tests, and deploys your Angular app to Minikube whenever you push code to GitHub.
🤔 What Do These Terms Mean and Why Use Them?
- CI/CD (Continuous Integration/Continuous Deployment): This is a set of practices that enable rapid and reliable delivery of applications.
- Continuous Integration (CI): The practice of regularly merging code changes from all developers into a central repository, followed by automated builds and tests.
- Why? Integrates code frequently to detect integration errors early, reducing bugs and simplifying debugging.
- Continuous Deployment (CD): The practice of automatically deploying all code changes that pass automated tests to a production or development environment without manual intervention.
- Why? Automates the release process, speeding up delivery, reducing manual errors, and allowing for faster feedback loops.
- Continuous Integration (CI): The practice of regularly merging code changes from all developers into a central repository, followed by automated builds and tests.
- GitHub Actions: A CI/CD platform integrated directly into GitHub. It allows you to automate tasks within your software development workflow, such as building, testing, and deploying code.
- Why? Provides an easy-to-use, cloud-native way to create automated workflows triggered by GitHub events (like pushes or pull requests), all managed directly within your repository.
🛠️ Tools We'll Use
| Tool | Purpose |
|---|---|
| GitHub Actions | Runs CI/CD workflows on GitHub |
| Minikube | Local Kubernetes cluster |
kubectl + docker-env |
Deploy images to Minikube’s Docker engine |
⚙️ Step 1: Prepare Your Local Environment
Since Minikube runs locally, the GitHub Action workflow cannot directly deploy to your Minikube cluster over the internet. For local CI/CD testing, we will:
- Build Docker images locally in Minikube’s Docker engine
- Deploy to Kubernetes using kubectl from local scripts
For production or cloud clusters, you’d push images to a registry like Docker Hub or ECR.
⚙️ Step 2: Create a Deployment Script (deploy.sh)
Create a simple shell script in your project root to:
- Set Minikube Docker environment
- Build your Angular Docker image
- Apply Kubernetes manifests
- Restart deployment
#!/bin/bash
echo "🔧 Setting Docker environment to Minikube..."
eval $(minikube docker-env)
echo "🐳 Building Docker image in Minikube..."
docker build -t angular-app:latest .
echo "📦 Applying Kubernetes manifests..."
kubectl apply -f angular-deployment.yaml
kubectl apply -f angular-service.yaml
kubectl apply -f angular-ingress.yaml
echo "♻️ Restarting deployment..."
kubectl rollout restart deployment/angular-app-deployment
echo "✅ Deployment script completed!"
💡 On Windows, you can run this in Git Bash or WSL.
Make it executable (in Git Bash or WSL):
chmod +x deploy.sh
⚙️ Step 3: Example GitHub Actions Workflow (.github/workflows/ci-cd.yml)
Add this workflow file to your repo to automate build & tests on GitHub:
name: CI/CD Pipeline
on:
push:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install dependencies
run: npm install
- name: Run Angular build
run: npm run build --configuration=production
- name: Run tests
run: npm test -- --watch=false
# Note: Deployment to local Minikube needs to be triggered locally
⚙️ Step 4: How to Trigger Deployment Locally
Since your Minikube cluster runs locally, you can deploy with your script manually after code changes:
./deploy.sh
Or you can automate this further with tools like GitHub Actions Runner on your local machine, but that’s an advanced topic.
🤝 Summary
- We created a deployment shell script that builds and deploys your Angular app inside Minikube.
- We set up a GitHub Actions workflow to build and test code on every push.
- You now have a simple local CI/CD pipeline to improve your development workflow!